#include "TestPlugin.h"
#include "Log.h"
#include "Server/PluginsManager.h"
#include "Game/IInventory.hpp"
#include "Managers/GameManager.h"
#include "Components/ComponentInventory.h"
#include "Network/Client.h"
#include "Game/PlayerData.h"

#include "GameSingleton.h"
#include "Network/PackageManager.h"
#include "Network/Packages/MessagePackage.h"
#include "Network/ServerRoot.h"

#include "SubsystemTickShow.h"

namespace PocketSurvival
{
    TestPlugin::TestPlugin()
    {
        gameManager = GameSingleton::singletonPtr->getSingleton<GameManager>();

        m_tickShow = gameManager->registerSubsystem<SubsystemTickShow>();
        GameSingleton::singletonPtr->getSingleton<GameManager>()->registerThreadUpdateSubsystem(m_tickShow);
    }

    const std::string &TestPlugin::getPluginName()
    {
        static const std::string pluginName = "测试插件";
        return pluginName;
    }

    const std::string &TestPlugin::getIntroduce()
    {
        static const std::string introduce = "\n/test (物品id) (数量) - 获取物品";
        return introduce;
    }

    uint32_t TestPlugin::getUseAuthLevel()
    {
        return 100;
    }

    AuthDisplayType TestPlugin::getDisplayType()
    {
        return AuthDisplayType::Authority;
    }

    void TestPlugin::processCmd(ChatObj &chatObj, std::vector<std::string> &cmdDataVec)
    {
        if(m_tickShow->showTick == true)
        {
            m_tickShow->showTick = false;
            chatObj.sendMessage("test", "关闭tick值输出");
        }
        else
        {
            m_tickShow->showTick = true;
            chatObj.sendMessage("test", "开启tick值输出");
        }
    }

    void TestPlugin::load() {}

    void TestPlugin::getCmds(std::vector<std::string> &cmdVec)
    {
        cmdVec.push_back("/test");
    }

} // namespace PocketSurvival


using namespace PocketSurvival;

extern "C" void initialize()
{
    GameSingleton::singletonPtr->getSingleton<PluginsManager>()->registerPlugin<TestPlugin>();
    Log::Info("成功加载 TestPlugin 插件");
}